class Solution(object):
    def calPoints(self, ops):
        """
        :type ops: List[str]
        :rtype: int
        """
        identifier = ['C', 'D', '+']
        stack = []
        for item in ops:
            if item not in identifier:
                stack.append(int(item))
            else:
                if item == 'C':
                    stack.pop()
                else:
                    if item == 'D':
                        stack.append(2 * stack[-1])
                    else:
                        stack.append(stack[-1] + stack[-2])
        return sum(stack)


data = Solution()
ops = ["1"]
print(data.calPoints(ops))